package com.aliyun.messagemgt.converter;

import com.aliyun.messagemgt.dto.MsgHandleLog;
import com.aliyun.messagemgt.dto.msg.ReceiverDTO;
import com.aliyun.messagemgt.entities.MsgHandleLogEntity;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import org.mapstruct.factory.Mappers;

import java.util.List;

/**
 * @ClassName: MsgHandleLogConverter
 * @Description:
 * @Author: wugongzi
 * @Date: 2021/9/13 18:58
 * @Version: 1.0
 */
@Mapper
public interface MsgHandleLogConverter {
    MsgHandleLogConverter INSTANCE = Mappers.getMapper(MsgHandleLogConverter.class);

    List<MsgHandleLog> msgHandleLogEntityList2msgHandleLogList(List<MsgHandleLogEntity> msgHandleLogEntityList);

    List<ReceiverDTO> msgHandleLogEntitys2receiverDTOList(List<MsgHandleLogEntity> msgHandleLogEntitys);

    @Mappings({
            @Mapping(source = "receiverId",target = "mobilePhone"),
            @Mapping(source = "receiverId",target = "userId"),
            @Mapping(source = "receiverName",target = "userName"),
            @Mapping(expression = "java(msgHandleLogEntity.getPushResultCode() == 1?\"成功\":\"失败\")",target = "status"),
            @Mapping(source = "timeCreate",target = "createTime")
    })
    ReceiverDTO msgHandleLogEntity2receiverDTO(MsgHandleLogEntity msgHandleLogEntity);
}
